package com.tl.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tl.common.annotation.Log;
import com.tl.common.core.controller.BaseController;
import com.tl.common.core.domain.AjaxResult;
import com.tl.common.enums.BusinessType;
import com.tl.app.domain.AppTagClerk;
import com.tl.app.service.IAppTagClerkService;
import com.tl.common.utils.poi.ExcelUtil;
import com.tl.common.core.page.TableDataInfo;

/**
 * 店员标签Controller
 * 
 * @author suhp
 * @date 2024-07-07
 */
@RestController
@RequestMapping("/app/tagClerk")
public class AppTagClerkController extends BaseController
{
    @Autowired
    private IAppTagClerkService appTagClerkService;

    /**
     * 查询店员标签列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppTagClerk appTagClerk)
    {
        startPage();
        List<AppTagClerk> list = appTagClerkService.selectAppTagClerkList(appTagClerk);
        return getDataTable(list);
    }

    /**
     * 导出店员标签列表
     */
    @Log(title = "店员标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppTagClerk appTagClerk)
    {
        List<AppTagClerk> list = appTagClerkService.selectAppTagClerkList(appTagClerk);
        ExcelUtil<AppTagClerk> util = new ExcelUtil<AppTagClerk>(AppTagClerk.class);
        util.exportExcel(response, list, "店员标签数据");
    }

    /**
     * 获取店员标签详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appTagClerkService.selectAppTagClerkById(id));
    }

    /**
     * 新增店员标签
     */
    @Log(title = "店员标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppTagClerk appTagClerk)
    {
        return toAjax(appTagClerkService.insertAppTagClerk(appTagClerk));
    }

    /**
     * 修改店员标签
     */
    @Log(title = "店员标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppTagClerk appTagClerk)
    {
        return toAjax(appTagClerkService.updateAppTagClerk(appTagClerk));
    }

    /**
     * 删除店员标签
     */
    @Log(title = "店员标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appTagClerkService.deleteAppTagClerkByIds(ids));
    }
}
